Skip to content

fix(desktop): reset seeded new-workspace draft when the modal is dismissed - #6239

Closed
andyst-dev wants to merge 3 commits into
ParadevAI:mainfrom
andyst-dev:fix/new-workspace-modal-reset-seeded-draft
Closed

andyst-dev wants to merge 3 commits into
ParadevAI:mainfrom
andyst-dev:fix/new-workspace-modal-reset-seeded-draft

Conversation

@andyst-dev

@andyst-dev andyst-dev commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5372

Problem

Clicking Configure on the "Setup scripts" sidebar card opens the New Workspace modal seeded with a setup-script prompt. If you dismiss the modal (Esc / outside click) without creating a workspace, that prompt stays in the draft. The next time you click + / New Workspace, the composer still opens pre-filled with it — even though you never asked to configure setup scripts.

Root cause

Every seed path (V2SetupScriptCard, GitHub issue/PR flows) does resetDraft() + updateDraft(...) before opening the modal — but the dismiss path (closeModal) only flipped isOpen. The seeded prompt remained in the draft store, so the next plain "New Workspace" open consumed it as if the user had typed it.

Fix

closeModal now also resets the draft store. Since every seed path already resets before seeding, the dismiss becomes the single cleanup point:

  • Esc / outside click / any close → draft wiped
  • seeded flows (Configure, issue, PR) are unaffected — they re-seed after their own reset
  • a plain "New Workspace" always opens empty, as before 1.17.0

Validation

new-workspace-modal.test.ts — 2 unit tests:

bun test: 2/2 pass · tsc --noEmit: 0 errors · Biome: clean.


Summary by cubic

Clears any seeded New Workspace draft on modal dismiss and preserves it only during the /new-workspace handoff. Previously dismiss left the seed in place; now dismiss wipes it, handoff keeps it, and leaving /new-workspace clears it (fixes #5372).

  • Changes
    • closeModal(options?: { resetDraft?: boolean }) now resets the draft by default; pass resetDraft: false for the /new-workspace handoff (used by DashboardNewWorkspaceModal before navigation).
    • Adds resetNewWorkspaceDraftOnRouteLeave and hooks it to the /new-workspace route onLeave to clear the preserved seed on route leave.
    • Adds tests for dismiss cleanup, empty reopen, handoff preservation, and route-leave cleanup.

Written for commit 2809a52. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Closing the new workspace modal now clears previously entered setup prompts.
    • Reopening the modal starts with an empty draft.
    • Moving from the modal to the full-page workspace setup preserves the entered prompt.
    • Drafts are cleared after leaving the full-page workspace setup flow.
  • Tests

    • Added coverage for draft clearing, reopening behavior, and prompt preservation.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 094f5103-1a3e-4223-ae1b-a30ab9a18cbb

📥 Commits

Reviewing files that changed from the base of the PR and between d37f5d6 and 2809a52.

📒 Files selected for processing (5)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/new-workspace/page.tsx
  • apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/DashboardNewWorkspaceModal.tsx
  • apps/desktop/src/renderer/stores/new-workspace-draft.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.test.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/DashboardNewWorkspaceModal.tsx
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.test.ts
  • apps/desktop/src/renderer/stores/new-workspace-draft.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/new-workspace/page.tsx

📝 Walkthrough

Walkthrough

The new-workspace modal now clears its draft when dismissed. The full-page handoff preserves a seeded draft by disabling reset. The route clears the preserved draft when navigation leaves the create flow. Tests cover each lifecycle.

Changes

New workspace draft lifecycle

Layer / File(s) Summary
Reset draft on modal close
apps/desktop/src/renderer/stores/new-workspace-modal.ts, apps/desktop/src/renderer/stores/new-workspace-modal.test.ts
closeModal accepts an optional reset flag and clears the draft by default. Tests verify dismissal and reopening with an empty prompt.
Preserve and clear the full-page handoff draft
apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/DashboardNewWorkspaceModal.tsx, apps/desktop/src/renderer/stores/new-workspace-draft.ts, apps/desktop/src/renderer/routes/_authenticated/_dashboard/new-workspace/page.tsx, apps/desktop/src/renderer/stores/new-workspace-modal.test.ts
The test-screen handoff closes the modal with resetDraft: false. The route clears the preserved draft on exit. Tests verify preservation during handoff and cleanup after navigation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to 2809a

The PR clears seeded workspace prompts when the modal is dismissed while preserving intended handoff behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes directly address #5372 by clearing drafts after dismissal while preserving and later cleaning up full-page handoffs.
Out of Scope Changes check ✅ Passed The tests, handoff preservation, and route-leave cleanup support the linked bug fix and do not introduce unrelated changes.
Title check ✅ Passed The title uses conventional commit format and clearly describes the primary fix for seeded draft cleanup on modal dismissal.
Description check ✅ Passed The description explains the problem, root cause, fix, linked issue, and validation results, but omits the template checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR resets the shared new-workspace draft whenever the modal store closes and adds regression coverage for ordinary dismissal. However, the same close action also participates in the full-page variant's handoff, where it now erases seeded context before navigation.

  • Reset all new-workspace draft fields from closeModal.
  • Add tests covering seeded-prompt cleanup and a subsequent empty open.
  • Preserve ordinary dismissal behavior while inadvertently breaking seeded full-page entry flows.

Confidence Score: 4/5

This PR should not merge until the full-page new-workspace handoff preserves seeded prompts and linked issue or pull-request context.

The new unconditional reset runs not only for dismissals but also immediately before the full-page variant navigates to a destination that relies on the same draft store, causing seeded entry flows to arrive empty.

Files Needing Attention: apps/desktop/src/renderer/stores/new-workspace-modal.ts

Important Files Changed

Filename Overview
apps/desktop/src/renderer/stores/new-workspace-modal.ts Adds draft cleanup to closeModal, but this also clears seeded state during the full-page variant's modal-to-page redirect.
apps/desktop/src/renderer/stores/new-workspace-modal.test.ts Adds focused coverage for dismissal cleanup, but does not cover the existing closeModal-based full-page handoff.

Sequence Diagram

sequenceDiagram
  participant Seed as Seeded entry point
  participant Draft as Draft store
  participant Modal as Modal store
  participant Router as Full-page redirect
  participant Page as New Workspace page
  Seed->>Draft: Store prompt or linked item
  Seed->>Modal: openModal(projectId)
  Modal->>Modal: Full-page variant handles open
  Modal->>Draft: closeModal() resets draft
  Modal->>Router: Navigate with projectId only
  Router->>Page: Render /new-workspace
  Page->>Draft: Read seeded context
  Draft-->>Page: Empty draft
Loading
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/renderer/stores/new-workspace-modal.ts:64
**Full-page handoff clears seeded draft**

When the full-page new-workspace variant handles a seeded setup-script, issue, or pull-request open, it calls `closeModal()` before navigating to `/new-workspace`. This reset erases the shared draft before the destination consumes it, causing the page to open without the seeded prompt or linked item.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(desktop): reset seeded new-workspace..." | Re-trigger Greptile

// prompt the user never asked for. Every seed path calls
// resetDraft() before updateDraft(), so resetting here is safe
// and makes the dismiss the single cleanup point.
useNewWorkspaceDraftStore.getState().resetDraft();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Full-page handoff clears seeded draft

When the full-page new-workspace variant handles a seeded setup-script, issue, or pull-request open, it calls closeModal() before navigating to /new-workspace. This reset erases the shared draft before the destination consumes it, causing the page to open without the seeded prompt or linked item.

Knowledge Base Used: Desktop App (Electron main + renderer)

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/stores/new-workspace-modal.ts
Line: 64

Comment:
**Full-page handoff clears seeded draft**

When the full-page new-workspace variant handles a seeded setup-script, issue, or pull-request open, it calls `closeModal()` before navigating to `/new-workspace`. This reset erases the shared draft before the destination consumes it, causing the page to open without the seeded prompt or linked item.

**Knowledge Base Used:** [Desktop App (Electron main + renderer)](https://app.greptile.com/personal-org-6810/-/custom-context/knowledge-base/superset-sh/superset/-/docs/desktop-app.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/renderer/stores/new-workspace-modal.ts">

<violation number="1" location="apps/desktop/src/renderer/stores/new-workspace-modal.ts:64">
P1: The experimental full-screen handoff loses every seeded workspace draft: opening Configure (or an issue/PR workspace) closes the store modal before navigating, and this new reset wipes the prompt/links that the destination screen is supposed to consume. Keep the redirect handoff separate from dismissal cleanup, or preserve/reapply the draft across that navigation.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant User
    participant UI as UI Components
    participant Modal as NewWorkspaceModalStore
    participant Draft as NewWorkspaceDraftStore

    Note over User,Draft: #5372: Fix seeded prompt persistence on dismiss

    alt Seeded Flow (e.g., V2SetupScriptCard "Configure")
        UI->>Draft: resetDraft()
        UI->>Draft: updateDraft({ prompt: "Write a setup script..." })
        UI->>Modal: openModal(projectId)
        Modal-->>UI: isOpen: true
        User->>UI: Presses Esc / clicks outside
        UI->>Modal: closeModal()
        Modal->>Modal: set({ isOpen: false })
        Modal->>Draft: resetDraft()  // NEW: clears leftover prompt
        Draft-->>Modal: prompt: ""
        Modal-->>UI: isOpen: false
    else Plain "New Workspace" open
        UI->>Modal: openModal(projectId)
        alt Draft was previously seeded and dismissed
            Draft-->>UI: prompt: ""  // cleared by closeModal
        else No prior seed
            Draft-->>UI: prompt: ""
        end
        UI-->>User: Empty composer ready
    end

    Note over Modal,Draft: Critical invariant: every seed path calls<br>resetDraft() before updateDraft(),<br>so closeModal() is the single cleanup point.
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

// prompt the user never asked for. Every seed path calls
// resetDraft() before updateDraft(), so resetting here is safe
// and makes the dismiss the single cleanup point.
useNewWorkspaceDraftStore.getState().resetDraft();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The experimental full-screen handoff loses every seeded workspace draft: opening Configure (or an issue/PR workspace) closes the store modal before navigating, and this new reset wipes the prompt/links that the destination screen is supposed to consume. Keep the redirect handoff separate from dismissal cleanup, or preserve/reapply the draft across that navigation.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/stores/new-workspace-modal.ts, line 64:

<comment>The experimental full-screen handoff loses every seeded workspace draft: opening Configure (or an issue/PR workspace) closes the store modal before navigating, and this new reset wipes the prompt/links that the destination screen is supposed to consume. Keep the redirect handoff separate from dismissal cleanup, or preserve/reapply the draft across that navigation.</comment>

<file context>
@@ -54,6 +55,13 @@ export const useNewWorkspaceModalStore = create<NewWorkspaceModalState>()(
+				// prompt the user never asked for. Every seed path calls
+				// resetDraft() before updateDraft(), so resetting here is safe
+				// and makes the dismiss the single cleanup point.
+				useNewWorkspaceDraftStore.getState().resetDraft();
 			},
 
</file context>

andyst-dev added a commit to andyst-dev/superset that referenced this pull request Aug 6, 2026
Round-1 review (ParadevAI#6239, greptile P1 + cubic P1): the full-page
new-workspace test arm calls closeModal() before navigating to
/new-workspace, where the destination screen consumes the seeded draft
(setup-script prompt, linked issue/PR). The new dismissal cleanup
wiped it, so the page opened empty.

closeModal now takes { resetDraft?: boolean } (default true = the ParadevAI#5372
dismissal cleanup). The handoff opts out with { resetDraft: false }.

3 unit tests (dismiss clears, fresh open empty, handoff preserves).
tsc 0 errors, biome clean.
@andyst-dev

Copy link
Copy Markdown
Contributor Author

Thanks — both points are addressed in 3ab3d57:

  • Full-page handoff preserves the seeded draft (greptile P1 + cubic P1): closeModal now takes { resetDraft?: boolean } (default true = the [bug] New Workspace modal keeps the setup-script prompt after dismissing Configure #5372 dismissal cleanup). The DashboardNewWorkspaceModal test arm opts out with { resetDraft: false } before navigating to /new-workspace, so the setup-script prompt / linked issue / PR survives the handoff and the destination screen consumes it.
  • New regression test: "full-page handoff preserves the seeded draft" asserts the prompt is intact after closeModal({ resetDraft: false }).

bun test: 3/3 pass · tsc --noEmit: 0 errors · Biome: clean.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/DashboardNewWorkspaceModal.tsx">

<violation number="1" location="apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/DashboardNewWorkspaceModal.tsx:58">
P2: Abandoning the full-page create flow can still prefill the next New Workspace: this handoff opts out of cleanup, but the destination's close handler is a no-op and leaving it does not reset the global draft. Preserve the draft only for the active handoff, then clear it when the page is abandoned or scope the handoff draft to that route.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

// Keep the seeded draft (setup-script prompt, linked issue/PR): the
// /new-workspace page consumes it after the handoff, so this close
// must not run the #5372 dismissal cleanup.
closeModal({ resetDraft: false });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Abandoning the full-page create flow can still prefill the next New Workspace: this handoff opts out of cleanup, but the destination's close handler is a no-op and leaving it does not reset the global draft. Preserve the draft only for the active handoff, then clear it when the page is abandoned or scope the handoff draft to that route.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/DashboardNewWorkspaceModal.tsx, line 58:

<comment>Abandoning the full-page create flow can still prefill the next New Workspace: this handoff opts out of cleanup, but the destination's close handler is a no-op and leaving it does not reset the global draft. Preserve the draft only for the active handoff, then clear it when the page is abandoned or scope the handoff draft to that route.</comment>

<file context>
@@ -52,7 +52,10 @@ export function DashboardNewWorkspaceModal() {
+		// Keep the seeded draft (setup-script prompt, linked issue/PR): the
+		// /new-workspace page consumes it after the handoff, so this close
+		// must not run the #5372 dismissal cleanup.
+		closeModal({ resetDraft: false });
 		void navigate({
 			to: "/new-workspace",
</file context>

@andyst-dev

Copy link
Copy Markdown
Contributor Author

Thanks - fixed in 0a3cfdd.

The seeded draft is now scoped to the active full-page create flow:

  • the modal-to-page handoff still preserves setup-script, issue, and PR seed data;
  • the /new-workspace route registers an onLeave cleanup;
  • abandoning or completing that route clears the global draft, so the next New Workspace starts empty.

Regression coverage verifies both sides of the lifecycle: handoff preservation and route-abandonment cleanup.

Validation:

  • focused Bun tests -> 4 passed
  • Desktop typecheck -> passed
  • Biome on the 3 changed files -> clean
  • git diff --check -> clean

@andyst-dev

Copy link
Copy Markdown
Contributor Author

Heads-up: this PR no longer rebases cleanly — the new-workspace draft/modal code it touches was refactored on main. The resetDraft parameter on closeModal has been removed (the seeded-draft reset logic moved/changed, now usePreSelectedSession drives the handoff), so the original change no longer applies to current main. I verified the branch is conflicted (mergeable=false).

Since the surrounding code has evolved past this change, I'm flagging it as obsolete unless a maintainer wants to revisit the draft-reset behaviour against the new modal. Happy to close it.

andyst-dev added a commit to andyst-dev/superset that referenced this pull request Aug 13, 2026
Round-1 review (ParadevAI#6239, greptile P1 + cubic P1): the full-page
new-workspace test arm calls closeModal() before navigating to
/new-workspace, where the destination screen consumes the seeded draft
(setup-script prompt, linked issue/PR). The new dismissal cleanup
wiped it, so the page opened empty.

closeModal now takes { resetDraft?: boolean } (default true = the ParadevAI#5372
dismissal cleanup). The handoff opts out with { resetDraft: false }.

3 unit tests (dismiss clears, fresh open empty, handoff preserves).
tsc 0 errors, biome clean.
@andyst-dev
andyst-dev force-pushed the fix/new-workspace-modal-reset-seeded-draft branch from 0a3cfdd to b27d1c3 Compare August 13, 2026 07:22
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

…issed

Clicking Configure on the Setup-scripts sidebar card seeds the new
workspace draft with a setup-script prompt and opens the modal. Dismissing
the modal (Esc / outside click) called closeModal, which only flipped
isOpen — the seeded prompt stayed in the persisted draft store, so the
next '+ / New Workspace' opened pre-filled with a prompt the user never
asked for (ParadevAI#5372).

closeModal now resets the draft store. Every seed path already calls
resetDraft() before updateDraft(), so the dismiss becomes the single
cleanup point and no seed flow is affected.

2 unit tests: dismiss clears the seeded prompt; a fresh open after
dismiss starts empty.
Round-1 review (ParadevAI#6239, greptile P1 + cubic P1): the full-page
new-workspace test arm calls closeModal() before navigating to
/new-workspace, where the destination screen consumes the seeded draft
(setup-script prompt, linked issue/PR). The new dismissal cleanup
wiped it, so the page opened empty.

closeModal now takes { resetDraft?: boolean } (default true = the ParadevAI#5372
dismissal cleanup). The handoff opts out with { resetDraft: false }.

3 unit tests (dismiss clears, fresh open empty, handoff preserves).
tsc 0 errors, biome clean.
@andyst-dev
andyst-dev force-pushed the fix/new-workspace-modal-reset-seeded-draft branch from b27d1c3 to 2809a52 Compare August 13, 2026 08:20
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@andyst-dev

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the v2 new-workspace modal this PR modified was removed from main by #7353 (refactor(desktop): remove the v2 new-workspace modal), and the replacement draft flow (NewWorkspaceModalDraftContext.tsx) already implements the same semantics: the seeded draft is reset on dismiss by default, with the handoff route opting out via closeAndReset: false (the exact opt-out pattern from this PR's { resetDraft: false }, per the greptile/cubic round). Nothing unique remains to rebase — closing cleanly.

@andyst-dev andyst-dev closed this Sep 9, 2026
@andyst-dev
andyst-dev deleted the fix/new-workspace-modal-reset-seeded-draft branch September 9, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] New Workspace modal keeps the setup-script prompt after dismissing Configure

1 participant